package org.nidy.programexercise.FileExercise;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;

public class FileExercise {
    public static void main(String[] args) throws IOException {
        File f =new File("D:\\java\\java\\src\\main\\java\\org\\nidy\\programexercise\\FileExercise\\FileExercise.java");
        System.out.println(f.getName());
//        Path path = new Path("D:\\java\\java\\src\\main\\java\\org\\nidy");
        System.out.println("============================================");
        String str ="src\\main\\java\\org\\nidy\\programexercise\\FileExercise\\Nidy.properties";
        File file = new File(str);
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());
        System.out.println(file.getParent());
        System.out.println(file.getParentFile());
        System.out.println(file.getFreeSpace());
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());

        if(!file.exists()){
            file.createNewFile();
        }
        System.out.println("============================================");
        File f1=new File("D:\\360Downloads");
        System.out.println(f1.isDirectory());
        System.out.println(f1.isFile());
        File[] files = f1.listFiles();
        for (File file1:files){
            System.out.println(file1);
        }
        String[] list = f1.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return true;
            }
        });
        System.out.println(Arrays.toString(list));
        System.out.println("============================================");
        File[] arr = File.listRoots();
        System.out.println(Arrays.toString(arr));


    }
}
